home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Toolbox / Visual Basic Toolbox (P.I.E.)(1996).ISO / graphics / bitlin / frmlha.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-05-23  |  10.1 KB  |  349 lines

  1. VERSION 2.00
  2. Begin Form frmlha 
  3.    AutoRedraw      =   -1  'True
  4.    Caption         =   "LHA file contents"
  5.    Height          =   4440
  6.    Left            =   825
  7.    LinkTopic       =   "Form1"
  8.    ScaleHeight     =   4035
  9.    ScaleWidth      =   3315
  10.    Top             =   1185
  11.    Width           =   3435
  12.    Begin CommandButton cmdVersion 
  13.       Caption         =   "LHA &Version"
  14.       Height          =   495
  15.       Left            =   2040
  16.       TabIndex        =   7
  17.       Top             =   1440
  18.       Width           =   1095
  19.    End
  20.    Begin PictureBox picFile2 
  21.       Height          =   615
  22.       Left            =   3720
  23.       Picture         =   FRMLHA.FRX:0000
  24.       ScaleHeight     =   585
  25.       ScaleWidth      =   465
  26.       TabIndex        =   6
  27.       Top             =   960
  28.       Width           =   495
  29.    End
  30.    Begin PictureBox PicFile1 
  31.       Height          =   615
  32.       Left            =   3720
  33.       Picture         =   FRMLHA.FRX:0302
  34.       ScaleHeight     =   585
  35.       ScaleWidth      =   465
  36.       TabIndex        =   5
  37.       Top             =   240
  38.       Width           =   495
  39.    End
  40.    Begin CommandButton cmdDelete 
  41.       Caption         =   "&Delete"
  42.       Height          =   495
  43.       Left            =   2040
  44.       TabIndex        =   4
  45.       Top             =   3240
  46.       Width           =   1095
  47.    End
  48.    Begin CommandButton cmdExtract 
  49.       Caption         =   "&Extract"
  50.       Height          =   495
  51.       Left            =   2040
  52.       TabIndex        =   3
  53.       Top             =   2040
  54.       Width           =   1095
  55.    End
  56.    Begin CommandButton cmdCancel 
  57.       Cancel          =   -1  'True
  58.       Caption         =   "&Cancel"
  59.       Height          =   495
  60.       Left            =   2040
  61.       TabIndex        =   2
  62.       Top             =   840
  63.       Width           =   1095
  64.    End
  65.    Begin CommandButton cmdOK 
  66.       Caption         =   "&OK"
  67.       Default         =   -1  'True
  68.       Height          =   495
  69.       Left            =   2040
  70.       TabIndex        =   1
  71.       Top             =   240
  72.       Width           =   1095
  73.    End
  74.    Begin ListBox lstLHAcontents 
  75.       FontBold        =   0   'False
  76.       FontItalic      =   0   'False
  77.       FontName        =   "Terminal"
  78.       FontSize        =   9.75
  79.       FontStrikethru  =   0   'False
  80.       FontUnderline   =   0   'False
  81.       Height          =   3540
  82.       Left            =   240
  83.       MultiSelect     =   2  '
  84.       TabIndex        =   0
  85.       Top             =   240
  86.       Width           =   1575
  87.    End
  88. Sub cmdCancel_Click ()
  89. ' set the frmlha.tag to null
  90.   frmLHA.Tag = ""
  91. ' hide the frmlha
  92. frmLHA.Hide
  93. End Sub
  94. 'Copyright 1995 by Hitoshi Ozawa
  95. Sub cmdDelete_Click ()
  96. Dim retcode As Integer
  97. Dim curpath As String
  98. Dim cnt
  99. Dim numitem
  100. 'Reset buffer size
  101. buffer = Space(szbuff)
  102. 'Save current path
  103. curpath = CurDir
  104. ChDrive Mid$(frmgetfile.Tag, 1, 2)
  105. ChDir frmgetfile.filFiles.Path
  106. numitem = lstLHAcontents.ListCount
  107. cnt = 0
  108. Do While cnt < numitem
  109.  If lstLHAcontents.Selected(cnt) Then
  110.    'Create LHA command
  111.    cmd = "d " & frmgetfile.Tag & " " & lstLHAcontents.List(cnt)
  112.    'Perform LHA operation
  113.     retcode = lha(cmd, buffer, szbuff)
  114.    'Check for error
  115.    If retcode <> 0 Then
  116.      MsgBox ("Error: " & retcode)
  117.      Exit Sub
  118.    End If
  119.    lstLHAcontents.RemoveItem cnt
  120.    numitem = numitem - 1
  121.  Else
  122.    cnt = cnt + 1
  123.  End If
  124. 'Return to original drive
  125. ChDrive Mid$(curpath, 1, 2)
  126. 'Return to original path
  127. ChDir curpath
  128. End Sub
  129. 'Copyright 1995 by Hitoshi Ozawa
  130. Sub cmdDelete_DragDrop (Source As Control, X As Single, Y As Single)
  131. Dim retcode As Integer
  132. Dim curpath As String
  133. Dim cnt
  134. Dim numitem
  135. 'Save current path
  136. curpath = CurDir
  137. ChDrive Mid$(frmgetfile.Tag, 1, 2)
  138. ChDir frmgetfile.filFiles.Path
  139. numitem = lstLHAcontents.ListCount
  140. cnt = 0
  141. Do While cnt < numitem
  142.  If lstLHAcontents.Selected(cnt) Then
  143.    'Create LHA command
  144.    cmd = "d " & frmgetfile.Tag & " " & lstLHAcontents.List(cnt)
  145.    'Perform LHA operation
  146.     retcode = lha(cmd, buffer, szbuff)
  147.    'Check for error
  148.    If retcode <> 0 Then
  149.      MsgBox ("Error: " & retcode)
  150.      Exit Sub
  151.    End If
  152.    lstLHAcontents.RemoveItem cnt
  153.    numitem = numitem - 1
  154.  Else
  155.    cnt = cnt + 1
  156.  End If
  157. 'Return to original drive
  158. ChDrive Mid$(curpath, 1, 2)
  159. 'Return to original path
  160. ChDir curpath
  161. End Sub
  162. 'Copyright 1995 by Hitoshi Ozawa
  163. Sub cmdDelete_DragOver (Source As Control, X As Single, Y As Single, State As Integer)
  164. Select Case State
  165.   Case 0
  166.     'change icon to release
  167.      lstLHAcontents.DragIcon = picFile2
  168.   Case 1
  169.     'change icon to release
  170.      lstLHAcontents.DragIcon = picFile1
  171. End Select
  172. End Sub
  173. 'Copyright 1995 by Hitoshi Ozawa
  174. Sub cmdExtract_Click ()
  175. Dim retcode As Integer
  176. Dim curpath As String
  177. Dim cnt
  178. 'Reset buffer size
  179. buffer = Space(szbuff)
  180. 'Save current path
  181. curpath = CurDir
  182. ChDrive Mid$(frmgetfile.Tag, 1, 2)
  183. ChDir frmgetfile.filFiles.Path
  184. For cnt = 0 To lstLHAcontents.ListCount - 1
  185.  If lstLHAcontents.Selected(cnt) Then
  186.    'Create LHA command
  187.    cmd = "e " & frmgetfile.Tag & " " & lstLHAcontents.List(cnt)
  188.    'Perform LHA operation
  189.     retcode = lha(cmd, buffer, szbuff)
  190.    'Check for error
  191.    If retcode <> 0 Then
  192.      MsgBox ("Error: " & retcode)
  193.      Exit Sub
  194.    End If
  195.  End If
  196. Next cnt
  197. 'Return to original drive
  198. ChDrive Mid$(curpath, 1, 2)
  199. 'Return to original path
  200. ChDir curpath
  201. 'refresh getfile file box
  202. frmgetfile.filFiles.Refresh
  203. End Sub
  204. 'Copyright 1995 by Hitoshi Ozawa
  205. Sub cmdExtract_DragDrop (Source As Control, X As Single, Y As Single)
  206. Dim retcode As Integer
  207. Dim curpath As String
  208. Dim cnt
  209. 'Save current path
  210. curpath = CurDir
  211. ChDrive Mid$(frmgetfile.Tag, 1, 2)
  212. ChDir frmgetfile.filFiles.Path
  213. For cnt = 0 To lstLHAcontents.ListCount - 1
  214.  If lstLHAcontents.Selected(cnt) Then
  215.    'Create LHA command
  216.    cmd = "e " & frmgetfile.Tag & " " & lstLHAcontents.List(cnt)
  217.    'Perform LHA operation
  218.     retcode = lha(cmd, buffer, szbuff)
  219.    'Check for error
  220.    If retcode <> 0 Then
  221.      MsgBox ("Error: " & retcode)
  222.      Exit Sub
  223.    End If
  224.  End If
  225. Next cnt
  226. 'Return to original drive
  227. ChDrive Mid$(curpath, 1, 2)
  228. 'Return to original path
  229. ChDir curpath
  230. 'refresh getfile file box
  231. frmgetfile.filFiles.Refresh
  232. End Sub
  233. 'Copyright 1995 by Hitoshi Ozawa
  234. Sub cmdExtract_DragOver (Source As Control, X As Single, Y As Single, State As Integer)
  235. Select Case State
  236.   Case 0
  237.     'change icon to release
  238.      lstLHAcontents.DragIcon = picFile2
  239.   Case 1
  240.     'change icon to release
  241.      lstLHAcontents.DragIcon = picFile1
  242. End Select
  243. End Sub
  244. 'Copyright 1995 by Hitoshi Ozawa
  245. Sub cmdOK_Click ()
  246. Dim retcode As Integer
  247. Dim curpath As String
  248. 'Check if file selected
  249. If lstLHAcontents.Text = "" Then
  250.   frmLHA.Tag = ""
  251.   frmLHA.Hide
  252. End If
  253. 'Save current path
  254. curpath = CurDir
  255. 'Change to file's drive and path
  256. ChDrive Mid$(frmgetfile.Tag, 1, 2)
  257. ChDir frmgetfile.filFiles.Path
  258. 'Check if file already exists
  259. On Error GoTo ExtFile
  260.  retcode = GetAttr(lstLHAcontents.Text)
  261.  retcode = MsgBox("Overwrite existing file?", 308, "File already exists!")
  262. If retcode = 6 Then
  263.    Kill lstLHAcontents.Text
  264.    GoTo ExtFile
  265.  End If
  266. Exit Sub
  267. ExtFile:
  268. 'Create LHA command
  269. cmd = "e " & frmgetfile.Tag & " " & lstLHAcontents.Text
  270. 'Perform LHA operation
  271. retcode = lha(cmd, buffer, szbuff)
  272. 'Check for error
  273. If retcode <> 0 Then
  274.  MsgBox ("LHA.DLL Error: " & retcode)
  275.  Exit Sub
  276. End If
  277. 'Return to original drive
  278. ChDrive Mid$(curpath, 1, 2)
  279. 'Return to original path
  280. ChDir curpath
  281. 'refresh getfile file box
  282. frmgetfile.filFiles.Refresh
  283. 'Assign selection to tag
  284. frmLHA.Tag = lstLHAcontents.Text
  285. frmLHA.Hide
  286. Exit Sub
  287. End Sub
  288. Sub cmdVersion_Click ()
  289. 'display LHA.DLL version information
  290. Dim retcode As Integer
  291. 'Perform LHA operation
  292. retcode = LhaGetVersion()           'get LHA.DLL version information
  293. retcode = MsgBox("Current Version: " & retcode, 0, "LHA.DLL Information")  'display version info
  294. End Sub
  295. 'Copyright 1995 by Hitoshi Ozawa
  296. Sub Form_Activate ()
  297. 'display contents of selected LZH file
  298. Dim cnt As Integer                    'loop counter
  299. Dim retcode As Integer                'return code
  300. Dim stptr                             'start position pointer
  301. Dim endptr                            'end position pointer
  302. 'Reset buffer size
  303. buffer = Space(szbuff) & Chr(0)       'reset buffer- add chr(0) to mark end of buffer
  304. 'Clear list box
  305. lstLHAcontents.Clear                  'clear contents list box
  306. frmLHA.Refresh                        'redraw dialog box
  307. 'Create LHA command
  308. cmd = "l " & frmgetfile.Tag           'make LHA command to list contents of LZH file
  309. 'Perform LHA operation
  310. retcode = lha(cmd, buffer, szbuff)    'perform LHA operation - call LHA.DLL function
  311. 'Check for error
  312. If retcode <> 0 Then                  'check if there was a LHA.DLL function error
  313.  MsgBox ("Error: " & retcode)
  314.  Exit Sub
  315. End If
  316. 'Extract only File name from file listing returned from LHA function call
  317. 'Skip past header
  318. endptr = InStr(buffer, "-")
  319. stptr = InStr(endptr, buffer, Chr(10))
  320. Do While Mid$(buffer, stptr, 1) <> "-"
  321. 'Skip past chr(10)
  322.   stptr = InStr(stptr, buffer, " ")
  323. 'Skip past spaces
  324.   stptr = 13 - Len(LTrim$(Mid$(buffer, stptr, 13))) + stptr
  325. 'Find end of file name
  326.   endptr = InStr(stptr, buffer, " ")
  327. 'Add filename to list
  328.   lstLHAcontents.AddItem Trim(Mid$(buffer, stptr, endptr - stptr))
  329. 'Skip to end of row
  330.   stptr = InStr(stptr, buffer, Chr(10)) + 1
  331. 'Check for going past end of buffer
  332.   If stptr >= szbuff Then
  333.     Exit Do
  334.   End If
  335. lstLHAcontents.Refresh                'update list box to display file names
  336. End Sub
  337. 'Copyright 1995 by Hitoshi Ozawa
  338. Sub lstLHAcontents_DblClick ()
  339. 'Execute the cmdOK_Click() procedure and close frmlha
  340. cmdOK_Click
  341. End Sub
  342. 'Copyright 1995 by Hitoshi Ozawa
  343. Sub lstLHAcontents_MouseDown (Button As Integer, Shift As Integer, X As Single, Y As Single)
  344. 'Change drag icon
  345. lstLHAcontents.DragIcon = picFile1
  346. 'Enable drag
  347. lstLHAcontents.Drag
  348. End Sub
  349.